<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Title</title>
    <link rel="stylesheet" href="../static/plugins/layui/css/layui.css">
</head>
<style>
    .ok-body {
        padding: 10px
    }
    .layui-form-item .layui-inline {
        margin-bottom: 5px;
        margin-right: 0px;
    }
    .layui-form-pane .layui-form-label {
        width: 90px;
    }
    .layui-form-item .layui-input-inline {
        width: 170px;
    }
</style>

<body>
<div class="ok-body">

    <div class="layui-row" style="margin-top: 15px">
        <form class="layui-form layui-form-pane">

            <div class="layui-form-item" style="margin-bottom: 5px;">

                <div class="layui-inline">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline" style="margin-right: 0px;">
                        <input type="text" name="username" class="layui-input" />
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">岗位名称</label>
                    <div class="layui-input-inline" style="margin-right: 0px;">
                        <select name="organizationId" lay-search>
                            <option value=""></option>
                        </select>
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">到岗时间</label>
                    <div class="layui-input-inline" style="margin-right: 0px;">
                        <input class="layui-input" name="arrivalTime" id="arrivalTime" autocomplete="off">
                    </div>
                </div>

            </div>

            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label">手机号码</label>
                    <div class="layui-input-inline" style="margin-right: 0px;">
                        <input class="layui-input" name="phone" maxlength="14" autocomplete="off">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">维修职称</label>
                    <div class="layui-input-inline" style="margin-right: 0px;">
                        <select name="titleId" lay-search>
                            <option value=""></option>
                        </select>
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">获证时间</label>
                    <div class="layui-input-inline" style="margin-right: 0px;">
                        <input class="layui-input" name="certificateTime" id="certificateTime" autocomplete="off">
                    </div>
                </div>

                <div class="layui-inline">
                    <button class="layui-btn  layui-btn-normal" style="margin-left: 10px" lay-submit
                            lay-filter="search">搜索
                    </button>

                    <span>
                        <button type="button" class="layui-btn layui-btn-warm" id="add" style="float: right;margin-left: 5px;">新增</button>
                        <button type="button" class="layui-btn layui-btn-danger" id="delete" style="float: right">删除</button>
                        <button type="button" class="layui-btn layui-btn-normal" id="export" style="float: right;margin-left: 70px;">导出</button>
                     </span>
                </div>
            </div>

        </form>
    </div>

    <hr class="layui-bg-orange">

    <table class="layui-hide" id="user" lay-filter="user"></table>
    <!--分页Div-->
    <div id="pageDiv"></div>

</div>

<script src="../static/plugins/layui/layui.js"></script>
<script src="../static/js/jquery-3.2.1.min.js"></script>
<script src="../static/js/jquery.base64.js"></script>
<script src="../static/js/device.js"></script>

<script th:inline="none">
    layui.use(['table','laypage','form','layer','laydate'], function(){
        var table = layui.table;
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;

        //到岗时间
        laydate.render({
            elem: '#arrivalTime'
            , format: 'yyyy-MM-dd'
        });

        //取得证书时间
        laydate.render({
            elem: '#certificateTime'
            , format: 'yyyy-MM-dd'
        });

        JJZ.initSelect(JJZ.named('organizationId'), '/organization/dataGrid', function (noError) {
            form.render(); //更新表单
        });

        JJZ.initSelect(JJZ.named('titleId'), '/title/dataGrid', function (noError) {
            form.render(); //更新表单
        });


        var tableName = 'user';
        var tableRenderObject = {
            elem: '#'+tableName
            ,title: '用户信息表'
            ,tableName:tableName
            ,searchCol:''
            ,searchValue:''
            ,defaultToolbar: ['filter', 'print']
            ,toolbar: true
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'username', title:'姓名',align:'center'}
                ,{field:'loginName', title:'登录名',align:'center'}
                ,{field:'organizationName', title:'岗位名称',align:'center'}
                ,{field:'arrivalTime', title:'入岗时间',align:'center',templet:function (d) {
                        return JJZ.FormatDate(d.arrivalTime,'yyyy-MM-dd');
                    }}
                ,{field:'titleName', title:'维修职称',align:'center'}
                ,{field:'certificateTime', title:'获得证书时间',align:'center',templet:function (d) {
                        return JJZ.FormatDate(d.certificateTime,'yyyy-MM-dd');
                    }}
                // ,{field:'jobNum', title:'工号',align:'center'}
                ,{field:'phone', title:'手机号',align:'center'}
                // ,{field:'gmtCreate', title:'创建日期',align:'center'}
                ,{fixed: 'right',align:'center', title:'操作',templet:function(d){
                        var detailUrl = 'javascript:JJZ.getRequestToPage("' + '/user/userInfo?id=' + d.id + '")';
                        return'<a href=' + detailUrl + ' class="layui-table-link">详情</a>&nbsp;&nbsp;' +
                            '<a href="javascript:JJZ.editPage(\''+tableName+'\','+d.id+')" class="layui-table-link">编辑</a>';
                    }}
            ]]
        };
        var myTable = new JJZ.MyTable(tableRenderObject);

        form.on('submit(search)', function(data){
            var encodeStr = $.base64.encode(JSON.stringify(data.field), 'utf-8');
            var param = 'json=' + encodeURIComponent(encodeStr);
            tableRenderObject.initParam = param;
            myTable.render();
            return false;
        });

        //新增，跳转至页面
        $('#add').click(function(){
           myTable.add();
        });

        //批量删除数据
        $('#delete').click(function(){
            var checkStatus = table.checkStatus('user')
            ,data = checkStatus.data;
            layer.confirm('确认删除？', function(index){
                myTable.delete(data);
                myTable.render();
                layer.close(index);
            });

        });

    });

</script>

</body>
</html>